﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Reactive.Linq;
using System.Threading;
using System.Xml.Serialization;
using TfL;
namespace tflConsole
{
    class Program
    {
        static void Main(string[] args)
        {
           
            CancellationTokenSource token = new CancellationTokenSource();
            TfL.TrackerNet tracker = new TrackerNet("http://cloud.tfl.gov.uk/TrackerNet/", "http://webservices.lul.co.uk/");
            //var feed = from s in tracker.StationStatus.IncidentsOnly.Poll(token.Token, 30000)
            //           select s;
            //feed.Subscribe(System.Console.WriteLine);

            var lineStatus = from s in tracker.LineStatus.Poll(token.Token, 1000)
                             select s;

            lineStatus.Subscribe((status)=> status.ForEach(System.Console.WriteLine));

            //var trainTimes = from t in tracker.TrainTimes("District").Poll()
            //                 where t.Name == "Victoria."
            //                 select t;
            //var disposible = trainTimes.Subscribe(System.Console.WriteLine);

            //var stationNames = tracker.StationNames.Poll();
            //stationNames.Subscribe(System.Console.WriteLine);

            //var stationTimes = from t in tracker.StationArrivals("Victoria").Poll()
            //                   select t;
            //var disposible = stationTimes.Subscribe(System.Console.WriteLine);
            
            System.Console.ReadKey();

            //disposible.Dispose();
            
            token.Cancel();
            
        }
    }
}
